package com.lanou.utils;

/**
 * Created by dllo on 18/2/28.
 */
public class AjaxResult {
    //所有数据接口(json)的返回格式
    private Boolean flag;
    private String msg;
    private Object data;

    @Override
    public String toString() {
        return "AjaxResult{" +
                "flag=" + flag +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }

    public static AjaxResult getOK(Object o){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setData(o);
        ajaxResult.setMsg("成功");
        ajaxResult.setFlag(true);
        return ajaxResult;
    }

    public static AjaxResult getNO(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setMsg(msg);
        ajaxResult.setFlag(false);
        return ajaxResult;
    }
    public static AjaxResult getOK(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setMsg(msg);
        ajaxResult.setFlag(true);
        return ajaxResult;
    }

    public Boolean getFlag() {
        return flag;
    }

    public void setFlag(Boolean flag) {
        this.flag = flag;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
